package com.ershi.spring.component.bp;

import com.ershi.spring.component.lifestyle.Yellow;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author 二十
 * @since 2021/10/14 1:18 上午
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

/*		if(bean instanceof Yellow){
			return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
		}*/
		System.out.println(beanName+"后置处理器的前置方法");
		return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		System.out.println(beanName+"后置处理器的后置方法");
		return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
	}
}
